// app.js
import { ZIM } from 'zego-zim-miniprogram';
App({
   apiimg:"https://www.zonghengxin.com/",
   apiurl:"https://www.zonghengxin.com/",
 // apiimg:"https://xcx.zonghengxin.com/",
 // apiurl:"https://xcx.zonghengxin.com/",
  pipei:false,
  kh_info:false,
  // apiimg:'/',
  refereeid:'',
  kaihei:'',
  pipei21:false,
  globalData: {
    zim: null,
    zimVersion: '',
    userInfo: null,
  },
  onLaunch() {
    this.globalData.zimVersion = ZIM.getVersion();
    this.globalData.zim = ZIM.create({ appID: 685322431 });
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    // console.log("fdgdfgdfgdfgdfg",ZIM.getVersion())

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
    setInterval(() => {
      let _this = this
      let params = {
        "token": wx.getStorageSync("user_token"),
      }
      wx.request({
        url: _this.apiurl + 'api/compete/khppSuccess',
        method: 'GET',
        data: params,
        header: {
          'content-type': 'application/x-www-form-urlencoded' // 修改请求
        },
        success(res) {
            if(res.data.data != ''){
              _this.kaihei = res.data.data;
              _this.pipei21 = true;
            } else {
              _this.pipei21 = false;
            }
        }
      })
  }, 3000);
  },
  globalData: {
    userInfo: null
  }
})
